package com.bright.hxj.qchz.mapper;

import com.bright.hxj.qchz.sql.SqlProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author txf
 * @date 2021/5/14 15:53
 * @Description
 */
public interface CommonMapper {

    /**
     * 查询数据
     * @param tableName
     * @param map
     * @return
     */
    @SelectProvider(type = SqlProvider.class, method = "selectSql")
    List<Map<String, Object>> selectData(String tableName, String columns, @Param("map") Map<String, Object> map, String orderBy);

    /**
     * 插入数据
     * @param map
     * @return
     */
    @InsertProvider(type = SqlProvider.class, method = "insertSql")
    Boolean insertData(String tableName, List<Map<String, Object>> map);

    /**
     * 修改数据
     * @param tableName
     * @param map
     * @return
     */
    @UpdateProvider(type = SqlProvider.class, method = "updateSql")
    Boolean updateData(String tableName, @Param("map") Map<String, Object> map);

    /**
     * 删除数据 用id
     * @param tableName
     * @param ids
     * @return
     */
    @DeleteProvider(type = SqlProvider.class, method = "deleteSqlByIds")
    Boolean deleteDataByIds(String tableName, @Param("ids") List<Integer> ids, String idColumnName);

    /**
     * 删除数据
     * @param tableName
     * @param map
     * @return
     */
    @DeleteProvider(type = SqlProvider.class, method = "deleteSql")
    Boolean deleteData(String tableName, Map<String, Object> map);

    /**
     * 查询数据 自定义语句
     * @param map
     * @return
     */
    @SelectProvider(type = SqlProvider.class, method = "selectByFullSql")
    List<Map<String, Object>> selectByFullSql(String sql, @Param("map") Map<String, Object> map);

}
